#include <iostream>

using namespace std;

const int N = 1e6 + 10;

int q[N];
int n, m;

int main(void)
{
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; i++)
        scanf("%d", &q[i]);

    int tmp;
    for (int i = 0; i < m; i++)
    {
        cin >> tmp;
        int l = 0, r = n - 1;
        int mid = (l + r) >> 1;
        while (l < r)
        {
            if (q[mid] < tmp)
                l = mid + 1;
            else if (q[mid] > tmp)
                r = mid - 1;
            else
                r = mid;
            mid = l + r >> 1;
        }
        if (q[l] == tmp)
            cout << l << ' ';
        else
            cout << -1 << ' ';

        l = 0, r = n - 1;
        mid = (l + r) >> 1;
        while (l < r)
        {
            if (q[mid] < tmp)
                l = mid + 1;
            else if (q[mid] > tmp)
                r = mid - 1;
            else
                l = mid;
            mid = (l + r + 1) >> 1;
        }

        if (q[l] == tmp)
            cout << l << '\n';
        else
            cout << -1 << '\n';
    }

    return 0;
}